// Créé avec XmlCppClassGenerator version 2.0 beta.

#include "Preferences.hpp"

#include <QtCore/QCoreApplication>

#include "Utils/SimpleCrypt.hpp"

Preferences* Preferences::Instance( 0 );

const qint64 Preferences::ClefCryptage( 0xd98691c7fe646343 );

const Preferences* Preferences::instance()
{
    if ( Instance == 0 )
    {
        QCoreApplication::setOrganizationName( "SoloArts" );
        QCoreApplication::setOrganizationDomain( "" );
        QCoreApplication::setApplicationName( "QCroqueMonster" );
        Instance = new Preferences();
    }

    return Instance;
}

const QString& Preferences::nomAgence() const
{
 return NomAgence;
}

const QString& Preferences::passAPI() const
{
 return PassAPI;
}

const unsigned& Preferences::probabiliteMinimale() const
{
 return ProbabiliteMinimale;
}

const unsigned& Preferences::gainMinimal() const
{
 return GainMinimal;
}

Preferences::Preferences()
    : QSettings(), NomAgence( "" ),
      PassAPI( "" ),
      ProbabiliteMinimale( 0u ),
      GainMinimal( 0u )
{
    SimpleCrypt crypto( ClefCryptage );

    NomAgence = value( "NomAgence", QString() ).toString();
    PassAPI   = crypto.decryptToString( value( "PassAPI",
                                                QString() ).toString() );
    ProbabiliteMinimale = value( "ProbabiliteMinimale",
                                 unsigned( 0u ) ).toUInt();
    GainMinimal = value( "GainMinimal", unsigned( 0u ) ).toUInt();
}

Preferences::~Preferences()
{}


